package com.GlobalPaint.app.ui.Home;

import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.AdapterView;
import android.widget.GridView;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.Toast;

import com.GlobalPaint.app.R;
import com.GlobalPaint.app.bean.General;
import com.GlobalPaint.app.ui.HTML.CommonHTML;
import com.GlobalPaint.app.ui.HTML.kongbaiActivity;
import com.GlobalPaint.app.ui.Home.talent.TalentActivity;
import com.GlobalPaint.app.utils.DataManager;
import com.umeng.socialize.UMShareListener;
import com.umeng.socialize.bean.SHARE_MEDIA;

import java.util.List;


public class QuanbuActivity extends AppCompatActivity implements View.OnClickListener{

    private GridView mGridView;
 /*   private int[] icon = {R.drawable.home_hy,R.drawable.home_sb,R.drawable.home_xy,R.drawable.home_tl,
            R.drawable.home_dt, R.drawable.home_qy,R.drawable.home_rc, R.drawable.hoem_sq,
            R.drawable.home_cp
    };*/

  /*  private String[] text = {"圈子","色板样品","最新技术交流","涂料产品",
            "行业动态资讯","企业展示","人才库","水性木器漆","涂料产品推广",
            };*/
    private List<General> mGeneralList;//要显示的数据集合
    private ListView lvGenerals;//ListView对象
    /**gridview的条目点击事件*/
    private MyGridViewItemClickListener mItemClickListener;
    private ImageView iv_goback;
    private TextView tv_common_center;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_quanbu);
        initView();

    }

    private void initView() {
      /*  mGridView = (GridView) findViewById(R.id.grid_view);
        iv_goback = (ImageView) findViewById(R.id.iv_goback);
        tv_common_center = (TextView) findViewById(R.id.tv_common_center);
        tv_common_center.setText("全部");
        iv_goback.setOnClickListener(this);
        mGeneralList = new ArrayList<General>();
        for (int i =0;i<icon.length;i++) {
            General general = new General();
            general.setIcon(icon[i]);
            general.setText(text[i]);
            mGeneralList.add(general);
        }
        mGridView.setSelector(new ColorDrawable(Color.TRANSPARENT));
        //设置gridview的适配器,通过构造传过去数据
        mGridView.setAdapter(new GridViewAdapter(mGeneralList));
        mItemClickListener = new MyGridViewItemClickListener();
        //设置griview的条目点击事件
        mGridView.setOnItemClickListener(mItemClickListener);*/
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()){
            case R.id.iv_goback:
                finish();
                  /*  new ShareAction(PaletteActivity.this)
                        .withText("hello")
                        .setDisplayList(SHARE_MEDIA.SINA,SHARE_MEDIA.QQ,SHARE_MEDIA.WEIXIN)
                        .setCallback(umShareListener)
                        .open();*/
        }
    }

    class MyGridViewItemClickListener implements AdapterView.OnItemClickListener {


        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            Intent intent = null;
            switch (position){
                //地图检索
                case 0:
                    intent = new Intent(QuanbuActivity.this, kongbaiActivity.class);
                    startActivity(intent);


                    break;
                //色板样品
                case 1:
                    DataManager.typeId = 121;
                    DataManager.typename = "图集";//图集
                    intent = new Intent(QuanbuActivity.this, CommonHTML.class);
                    startActivity(intent);
                    break;
                case 3:
                    intent = new Intent(QuanbuActivity.this, kongbaiActivity.class);
                    startActivity(intent);
                    break;

                case 2:
                    intent = new Intent(QuanbuActivity.this, kongbaiActivity.class);
                    startActivity(intent);
                    break;

                case 4:
                    DataManager.typeId = 114;
                    DataManager.typename = "文章";
                    intent = new Intent(QuanbuActivity.this, CommonHTML.class);
                    startActivity(intent);
                    break;

                case 5:
                    DataManager.typeId = 124;
                    DataManager.typename = "文章";
                    intent = new Intent(QuanbuActivity.this, CommonHTML.class);
                    startActivity(intent);
                    break;
                //人才库
                case 6:
                    intent = new Intent(QuanbuActivity.this, TalentActivity.class);
                    startActivity(intent);
                    break;
                //水性木器漆专区
                case 7:
                    DataManager.typeId = 127;
                    DataManager.typename = "文章";
                    intent = new Intent(QuanbuActivity.this, CommonHTML.class);
                    startActivity(intent);
                    break;
                //涂料产品推广专区
                case 8:
                    DataManager.typeId = 150;
                    DataManager.typename = "文章";
                    intent = new Intent(QuanbuActivity.this, CommonHTML.class);
                    startActivity(intent);
                    break;
            }
        }
    }
    //分享回调
    private UMShareListener umShareListener = new UMShareListener() {
        @Override
        public void onStart(SHARE_MEDIA platform) {

            //分享开始的回调
        }
        @Override
        public void onResult(SHARE_MEDIA platform) {
            Toast.makeText(QuanbuActivity.this, platform + " 分享成功啦", Toast.LENGTH_SHORT).show();

        }

        @Override
        public void onError(SHARE_MEDIA platform, Throwable t) {
            Toast.makeText(QuanbuActivity.this,platform + " 分享失败啦", Toast.LENGTH_SHORT).show();

        }

        @Override
        public void onCancel(SHARE_MEDIA platform) {
            Toast.makeText(QuanbuActivity.this,platform + " 分享取消了", Toast.LENGTH_SHORT).show();

        }
    };
}
